import { createStore } from 'redux'

let initState = {
  name: "初始名",
  age: 13,
  sex: "男",
  color: 'red'
}
function reducer(state, action) {
  state = state || initState
  switch (action.type) {
    case 'changeName':
      return {
        ...state,
        name: action.nnn
      }
    case "changeAge":
      return {
        ...state,
        age: state.age + action.aaa
      }
    case "changeSex":
      return {
        ...state,
        sex: action.sss
      }
    case "changeColor":
      return {
        ...state,
        color: action.ccc
      }
    default:
      return {
        ...state
      }
  }
}
let store = createStore(reducer)

export default store

// react-redux  链接react和redux的一个桥梁